//    Copyright 2009-2011 Ateeq Sharfuddin, Xiaofan Feng.
//    This file is part of Project Viatei.
//
//    Project Viatei is free software: you can redistribute it and/or modify
//    it under the terms of the GNU Lesser General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    Project Viatei is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU Lesser General Public License for more details.
//
//    You should have received a copy of the GNU Lesser General Public License
//    along with Project Viatei.  If not, see <http://www.gnu.org/licenses/>.

#include "boyermoore.h"
#include "fasthorspool.h"
#include "parallelfhp.h"

#include <iostream>

int main(int argc, char ** argv)
{
	std::string text = "The quick brown fox jumps over the lazy dog.";
	std::string pats [] = { "quick", "fox", "the", "dog", "" };

	boyermoore::horspool::parallel::init();

	typedef  std::list<std::string::size_type> (* find) ( const std::string & pattern, const std::string & inText );

	std::string names [] = { "BM", "MHP", "ParallelHP", "" };
	find		finders [] = {	boyermoore::find,
								boyermoore::horspool::machineword::find,
								boyermoore::horspool::parallel::find,
								NULL };

	std::string p;
	size_t i = 0;
	for ( p = pats[i]; p.length() > 0 ; p = pats[++i] )
	{
		std::cout << "String: " << p << std::endl;

		std::list<std::string::size_type> list;
		std::list<std::string::size_type>::iterator i;

		for (size_t j = 0; finders[j] != 0; ++j)
		{
			find f = finders[j];
			std::string n = names[j];

			list = f(p, text);
			std::cout << "  " << n << std::endl;
		
			for (i = list.begin(); i != list.end(); ++i)
				std::cout << "----offset: " << *i << std::endl;
		}

		std::cout << std::endl;
	}


	return 0;
}